﻿@model FollowPeers.Models.Course

@{
    ViewBag.Title = "New Conversation";
    FollowPeers.Models.FollowPeersDBEntities followPeersDB = new FollowPeers.Models.FollowPeersDBEntities();
    string name = Membership.GetUser().UserName;
    FollowPeers.Models.UserProfile myprofile = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserName == name);
 }

@Html.Partial("_Header")
@Html.Partial("_SideBar1")
@Html.Partial("CourseRightSideBar")

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
        <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
        <script src=@Url.Content("~/Scripts/jquery.bgiframe.js") type="text/javascript"></script>
        <script src=@Url.Content("~/Scripts/jquery.mcdropdown.js") type="text/javascript"></script>
        <link rel="stylesheet" type="text/css" href="../../Content/css/jquery.mcdropdown.css" />
<div class="grid_9">
    <div class="box">
        <h2 style="height: 20px">Course Details</h2>
            <fieldset>
                @{
                    
                    if (false)
                    {
                       <p>You have not followed anyone & no body is following you. Please follow someone to send them a message.</p>
                    }
                    else
                    {   <legend style="width:80%; height: 40px; padding-top:10px;"><img src="@Model.PhotoUrl" style="width:24px; height:24px; padding:5px 2px 5px 2px; display:inline-block; float:left;"/>@Html.DisplayFor(m => Model.CourseName)</legend>
                        <table>
                            <tr>
                                <td>
                                    <div style="padding:5px 0px 5px 5px;font-size: 0.9em; font-weight: normal; border:0 none black;">Description: @Model.CourseDescription</div>
                                </td>
                            </tr>
                            
                            @if(Model.StartDate!=null)
                            {
                                <tr>
                                     <td>
                                        <div style="padding:5px 0px 5px 5px;font-size: 0.9em; font-weight: normal; border:0 none black;">Course Starts: @Model.StartDate</div>
                                    </td>
                                </tr>
                            }
                            @if(Model.EndDate!=null)
                            {
                                <tr>
                                     <td>
                                        <div style="padding:5px 0px 5px 5px;font-size: 0.9em; font-weight: normal; border:0 none black;">Course Ends: @Model.EndDate</div>
                                    </td>
                                </tr>
                            }
                            @{
                                string path = HttpRuntime.AppDomainAppPath;
                                string newpath = path + "\\Content\\Files\\"+Model.Owner.UserName+"\\Courses\\"+Model.CourseName+"\\";
                                var directoryInfo = new DirectoryInfo(newpath);
                                if (directoryInfo.Exists)
                                {
                                    string[] readtext = File.ReadAllLines(newpath + "uploadedList.txt");
                                    if (readtext == null || readtext.Length == 0)
                                    {
                                
                                        <p>There are no uploaded files</p>
                                    
                                    }

                                    else
                                    {
                                        <p>Course Videos</p>
                                        int LectureNumber =1;
                                        foreach (string fileName in readtext)
                                        {
                                            int dot = fileName.IndexOf(".");
                                            if(dot>0)
                                            {
                                                string OnlyFileName = fileName.Substring(0, dot);
                                                <tr>
                                                    <td>
                                                        <div>
	                                                      <p>Lecture @LectureNumber: @OnlyFileName</p>
	                                                      <video poster="http://www.dieckmann-aroma-kaffee.de/video/start_video_528.jpg" width="320" height="240" controls>
	                                                      <source src="/Content/Files/@Model.Owner.UserName/Courses/@Model.CourseName/@fileName" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'>
	                                                      </video>
	                                                    </div>
                                                    </td>
                                                </tr>
                                            }
                                            LectureNumber += 1;
                                        }
                                    }
                                }
                              }
                            
                        </table>
                       
                        <div>
                            @Html.ActionLink("Add Videos To This Course", "CourseAddVideo",new { id = Model.CourseId})
                        </div>
                    }
                }
                
            </fieldset>

        <div>
            @Html.ActionLink("Back to Browse", "Index")
        </div>
    </div>
</div>
@Html.Partial("_Footer")